package middleware

import (
	"bytes"
	"github.com/gin-gonic/gin"
	"io/ioutil"
	. "zimuzu_cvn_web_api/pkg/e"
)

func TrackLog() gin.HandlerFunc {
	return func(c *gin.Context) {
		Log("Info", " [Start Function]: ", c.Request.URL)
		bodyBytes, _ := ioutil.ReadAll(c.Request.Body)
		c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes))
		bodyStr := string(bodyBytes)
		Log("Info", " [PARAMS_POST]: ", bodyStr)
		c.Next()
	}
}
